CheckToolboxPaths.m 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. %==========================================%
  2. % Check if required paths have been added. %
  3. % Last modified: Jan.15, 2014 %
  4. %==========================================%
  5. % Copyright (C) 2013-2014, Michael J. Cheung
  6. %
  7. % This file is a part of the MEG & PLS Pipeline (MEGPLS). For more
  8. % details, see the documentation included with the software package.
  9. %
  10. % MEGPLS is free software: you can redistribute it and/or modify it under
  11. % the terms of the GNU General Public License version 2 as published by
  12. % the Free Software Foundation. This program is distributed in the hope
  13. % that it will be useful, but WITHOUT ANY WARRANTY; without even the
  14. % implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  15. % See the GNU General Public License for more details.
  16. %
  17. % You should have received a copy of the GNU General Public License along
  18. % with this program. If not, you can download the license here:
  19. % <http://www.gnu.org/licenses/old-licenses/gpl-2.0>.
  20. function CheckToolboxPaths(PipelineRootDir)
  21. % Check pipeline root directory:
  22. if ~exist([PipelineRootDir,'/MEGPLS_COMPONENTS'], 'dir')
  23. message = {'Error:'; '';
  24. 'Specified folder does not seem to be pipeline root directory.';
  25. 'Cannot find MEGPLS_COMPONENTS folder in specified directory.'};
  26. msgbox(message, 'Error:')
  27. return;
  28. end
  29. % Check if pipeline paths added:
  30. CheckPipe1 = which('InstallationGUI.m');
  31. CheckPipe2 = which('MEGpipeline_RunPLS.m');
  32. if isempty(CheckPipe1) || isempty(CheckPipe2)
  33. addpath(genpath(PipelineRootDir));
  34. rmpath([PipelineRootDir,'/DEFAULT_SETTINGS']); % Only want to call the ones in AnalysisID
  35. rmpath([PipelineRootDir,'/TEMPORARY_FIXES']); % Want to call from Fieldtrip toolbox
  36. end
  37. % Check if toolbox paths added:
  38. CheckFT = which('ft_defaults.m');
  39. CheckSPM = which('spm_get_defaults.m');
  40. CheckAFNIMatlab = which('BrikLoad.m');
  41. if isempty(CheckFT) || isempty(CheckSPM) || isempty(CheckAFNIMatlab)
  42. if exist([PipelineRootDir,'/ToolboxPaths.mat'], 'file')
  43. ToolboxPaths = load([PipelineRootDir,'/ToolboxPaths.mat']);
  44. % Add Fieldtrip toolbox:
  45. if ~exist([ToolboxPaths.paths.Fieldtrip,'/ft_defaults.m'], 'file')
  46. ErrMsg = 'ERROR: Reselect Fieldtrip toolbox. Re-run InstallationGUI.';
  47. msgbox(ErrMsg);
  48. error(ErrMsg);
  49. else
  50. addpath(ToolboxPaths.paths.Fieldtrip);
  51. ft_defaults
  52. end
  53. % Add SPM8 toolbox:
  54. if ~exist([ToolboxPaths.paths.SPM,'/spm_get_defaults.m'], 'file')
  55. ErrMsg = 'ERROR: Reselect SPM8 toolbox. Re-run InstallationGUI.';
  56. msgbox(ErrMsg);
  57. error(ErrMsg);
  58. else
  59. addpath(ToolboxPaths.paths.SPM);
  60. end
  61. % Add AFNI-Matlab toolbox:
  62. if ~exist([ToolboxPaths.paths.AFNIMatlab,'/BrikLoad.m'], 'file')
  63. ErrMsg = 'ERROR: Reselect AFNI-Matlab toolbox. Re-run InstallationGUI.';
  64. msgbox(ErrMsg);
  65. error(ErrMsg);
  66. else
  67. addpath(ToolboxPaths.paths.AFNIMatlab);
  68. end
  69. else
  70. msgbox('ERROR: Toolbox paths not set. Run InstallationGUI.m first.')
  71. error('ToolboxPaths not set. Run InstallationGUI.m first.');
  72. end
  73. end